<?php
namespace app\admin\model;
use think\Model;
use think\Db;

class BusPlatPhoneLimit extends Model
{
    protected $table = 'bus_plat_phone_limit';

    public function getDataList($request)
    {
    	$data = $this->alias("p")
    	->field("p.*,t.type_desc,pf.platfrom")
    	->join("bus_plat_phone_limit_type t","p.type=t.id","left")
    	->join("bus_platfrom pf","p.plat_id=pf.plat_id","left");

    	if($request['plat_id'])
    	{
    		$data = $data->where('p.plat_id',$request['plat_id']);
    	}

    	$data = $data->order('p.id desc')
            ->paginate($request['limit'], false, ['query'=>$request])
            ->each(function($item, $key){

            	$item->plat_id = $item->plat_id . $item->platfrom;

                switch ($item->status) {
                    case 0:
                        $item->status_ = '<span class="layui-badge layui-bg-orange">已禁用</span>';
                        break;
                    case 1:
                        $item->status_ = '<span class="layui-badge layui-bg-green">已开启</span>';
                        break;

                    default:
                        $item->status_ = '';
                        break;
                }
            })->toarray();

    	return $data;

    }
}